package com.tjp.subject.common.enums;

import lombok.Data;
import lombok.Getter;

/**
 * @program: jz-club
 * @description: 返回结果枚举
 * @author: aaronTang
 * @create: 2024-02-22
 */
@Getter
public enum ResultCodeEnum {

    SUCCESS(200, "成功"),
    FAIL(500, "失败"),
    UNKNOWN(0, "未知错误");


    public int code;
    public String desc;

    ResultCodeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ResultCodeEnum getByCode(int codeVal) {
        for (ResultCodeEnum resultCodeEnum : ResultCodeEnum.values()) {
            if (resultCodeEnum.getCode() == codeVal) {
                return resultCodeEnum;
            }
        }
        return null;
    }


}
